package CanvaWeb.CanvaWeb.Repository;

import CanvaWeb.CanvaWeb.pojo.Room;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface RoomRepository extends JpaRepository<Room, Long> {
    @Query("SELECT r FROM Room r WHERE r.status = :status AND r.currentPlayers < r.capacity")
    List<Room> findAvailableRooms(@Param("status") String status);
    boolean existsById(Long id);
    Optional<Room> findById(Long roomId);
    List<Room> findByNameContainingIgnoreCase(String name);
}

